class_name LaserShooter
extends Node2D

@onready var laser_beam: LaserBeam = $LaserBeam
@export var laser_shoot_interval: float = 6.0
@export var shoot_start_delay: float = 0
var shoot_start_delay_timer: float = 0
var laser_shoot_timer: float = 0
@onready var animation_player: AnimationPlayer = $AnimationPlayer

@export var attack: float = 30
@export var critical_rate: float = 0.5
@export var critical_bonus: float = 0.5
@export var knockback: float = 250
@export var hit_cam_shake_strength: float = 0.7
@export var hit_cam_shake_duration: float = 0.1


func _ready() -> void:
	laser_beam.set_is_enemy(true)
	laser_beam.sender = null
	laser_beam.attack = attack
	laser_beam.critical_rate = critical_rate
	laser_beam.critical_bonus = critical_bonus
	laser_beam.knockback = knockback
	laser_beam.hit_cam_shake_strength = hit_cam_shake_strength
	laser_beam.hit_cam_shake_duration = hit_cam_shake_duration
	
	animation_player.play("idle")
	
	shoot_start_delay_timer = shoot_start_delay
	

func _physics_process(delta: float) -> void:
	shoot_start_delay_timer -= delta
	if shoot_start_delay_timer > 0: return
	
	laser_shoot_timer -= delta
	if laser_shoot_timer <= 0:
		laser_shoot_timer = laser_shoot_interval
		shoot()
		
		
func shoot():
	animation_player.play("shoot")
	
